import AImage from '@/components/AImage';
import { Space } from 'antd';
import React from 'react';

export const columns = ({ handleEdit }) => [
  {
    title: '商品名称',
    dataIndex: 'item',
    render: (_, record) => {
      return (
        <React.Fragment>
          <div style={{ display: 'flex', alignItems: 'center' }}>
            <div>
              <AImage width={80} height={80} src={record?.mainGraph} />
            </div>
            <Space direction="vertical" style={{ marginLeft: 8, flex: 1 }}>
              <div>{record?.itemName}</div>
              <div style={{ padding: 0, margin: 0 }}>ID：{record?.id}</div>
            </Space>
          </div>
        </React.Fragment>
      );
    },
  },
  {
    title: '商品状态',
    dataIndex: 'onShelf',
    width: 120,
    render: (_, record) => {
      if (record?.groupType === 3) {
        return <span>仓库中</span>;
      }
      if (record?.onShelf === 2 && record?.groupType === 1) {
        return <span>待开售</span>;
      }
      if (record?.onShelf === 2 && record?.groupType === 2) {
        return <span>出售中</span>;
      }
    },
  },
  {
    title: '商品价格',
    dataIndex: 'price',
    width: 120,
    valueType: 'digit',
    render: (_, record) => <div>￥{record.price}</div>,
  },
  {
    title: '操作',
    align: 'left',
    render: (record) => (
      <div>
        {!record.isPointsItem && <a onClick={() => handleEdit('edit', record)}>参与积分兑换</a>}
        {record.isPointsItem && <a style={{ color: '#ccc' }}>已参与</a>}
      </div>
    ),
  },
];
